﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Cl.Model.Results
{
    /// <summary>
    /// 获取结果
    /// </summary>
    public class GetResult
    {
        /// <summary>
        /// 返回错误
        /// </summary>
        /// <param name="msg"></param>
        /// <returns></returns>
        public static ResultInfoModel Error(string msg)
        {
            return new ResultInfoModel
            {
                Message = msg,
                IsSuccess = false,
                ResultCode = 400
            };
        }

        /// <summary>
        /// 返回错误（带数据）
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="msg"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public static ResultInfoModel Error<T>(string msg, T data)
        {
            return new ResultInfoModel
            {
                Message = msg,
                IsSuccess = false,
                ReturnData = data,
                ResultCode = 400
            };
        }

        /// <summary>
        /// 返回成功
        /// </summary>
        /// <param name="msg"></param>
        /// <returns></returns>
        public static ResultInfoModel Success(string msg = "")
        {
            return new ResultInfoModel
            {
                Message = msg,
                IsSuccess = true,
                ResultCode = 200
            };
        }

        public static ResultInfoModel Success<T>(string msg, T data)
        {
            return new ResultInfoModel
            {
                Message = msg,
                IsSuccess = true,
                ReturnData = data,
                ResultCode = 200
            };
        }

        public static ResultInfoModel Success(string msg, dynamic data)
        {
            return new ResultInfoModel
            {
                Message = msg,
                IsSuccess = true,
                ReturnData = data,
                ResultCode = 200
            };
        }
    }
}
